//
//  SchoolRecruitInfoViewController.m
//  edu
//
//  Created by baobaodp on 13-8-29.
//  Copyright (c) 2013年 baobaodp. All rights reserved.
//

#import "SchoolRecruitInfoViewController.h"
#import "SchoolRecruitInfoCell.h"
#import "Record.h"
#import "DBbase.h"
#import "EduViewController.h"


@interface SchoolRecruitInfoViewController ()

@end

@implementation SchoolRecruitInfoViewController

@synthesize m_record;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark -
#pragma mark Table Data Source Methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80;
}
- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    [self getRecords];
    return [self.datas count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentifier = @"SchoolRecruitInfoCellIdentifier";
    
    SchoolRecruitInfoCell *cell = (SchoolRecruitInfoCell *)[tableView
                                        dequeueReusableCellWithIdentifier: cellIdentifier];
    if (cell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SchoolRecruitInfoCell"
                                                     owner:self options:nil];
        for (id oneObject in nib)
            if ([oneObject isKindOfClass:[SchoolRecruitInfoCell class]])
                cell = (SchoolRecruitInfoCell *)oneObject;
    }
	
    //    NSUInteger row = [indexPath row];
    //    [cell setData:[self.estimates objectAtIndex:row]];
    
    NSUInteger row = [indexPath row];
    [cell setData:[self.datas objectAtIndex:row] index:row];
    
    return cell;
}

- (void) setData:(Record *) record index: (int) rowIndex
{
    self.m_record= record;
}

-(void)getRecords
{
    NSString *sch_Id = [m_record getFieldValueByName:@"sch_Id"] ;
    
    NSString *querySql = [NSString stringWithFormat:@"select T1.* from T_Souce T1 where T1.sch_Id = %@ order by T1.S_Ym " ,sch_Id];
    
    const char *sql = [querySql UTF8String];
    
    self.datas = getDbRecords(sql,@"T_Souce",[NSArray arrayWithObjects:@"soucd_Id", nil]);
}


@end
